-
Notifications
You must be signed in to change notification settings - Fork 90
fix(driver): make OpCode unsafe #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request converts the OpCode trait from a regular trait to an unsafe trait across different system implementations (IOCP, io-uring, polling, stub, and fusion). The changes update the trait definitions and some (but not all) implementations to use the unsafe keyword.
Changes:
- Modified
OpCodetrait definitions to beunsafe traitin multiple platform-specific modules - Updated specific non-generic
OpCodeimplementations to useunsafe impl(e.g., OpenFile, CloseFile, PathStat, various filesystem operations) - Left many generic implementations unchanged (without
unsafekeyword)
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| compio-runtime/tests/event.rs | Updated WaitEvent OpCode implementation to unsafe |
| compio-process/src/windows.rs | Updated WaitProcess OpCode implementation to unsafe |
| compio-driver/src/sys/stub/op.rs | Made trait unsafe and updated several specific implementations, but missed generic ones |
| compio-driver/src/sys/stub/mod.rs | Changed OpCode trait definition to unsafe |
| compio-driver/src/sys/poll/op.rs | Updated specific OpCode implementations to unsafe |
| compio-driver/src/sys/poll/mod.rs | Changed OpCode trait definition to unsafe |
| compio-driver/src/sys/iour/op.rs | Updated specific OpCode implementations to unsafe |
| compio-driver/src/sys/iour/mod.rs | Changed OpCode trait definition to unsafe |
| compio-driver/src/sys/iocp/op.rs | Updated CloseFile and CloseSocket to unsafe |
| compio-driver/src/sys/iocp/mod.rs | Changed OpCode trait definition to unsafe with safety documentation |
| compio-driver/src/sys/fusion/mod.rs | Changed OpCode trait definition to unsafe but missed blanket impl |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -96,21 +96,21 @@ impl<T: IoVectoredBuf, S: AsFd> OpCode for WriteVectored<T, S> {} | |||
|
|
|||
| impl<S: AsFd> OpCode for Sync<S> {} | |||
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for Sync {}
| impl<S: AsFd> OpCode for Sync<S> {} | |
| unsafe impl<S: AsFd> OpCode for Sync<S> {} |
| impl OpCode for CreateSocket {} | ||
| unsafe impl OpCode for CreateSocket {} | ||
|
|
||
| impl<S: AsFd> OpCode for ShutdownSocket<S> {} |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for ShutdownSocket {}
| impl<S: AsFd> OpCode for ShutdownSocket<S> {} | |
| unsafe impl<S: AsFd> OpCode for ShutdownSocket<S> {} |
| impl<S: AsFd> OpCode for Accept<S> {} | ||
|
|
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These implementations of the unsafe trait OpCode must be marked with unsafe. Change to: unsafe impl<S: AsFd> OpCode for Accept {} and unsafe impl<S: AsFd> OpCode for Connect {}
| pub trait OpCode: PollOpCode + IourOpCode {} | ||
| pub unsafe trait OpCode: PollOpCode + IourOpCode {} | ||
|
|
||
| impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {} |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blanket implementation must be marked as unsafe since it implements the unsafe trait OpCode. Change this to: unsafe impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {}
| impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {} | |
| unsafe impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {} |
| impl OpCode for CloseFile {} | ||
| unsafe impl OpCode for CloseFile {} | ||
|
|
||
| impl<S: AsFd> OpCode for TruncateFile<S> {} |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for TruncateFile {}
| impl<S: AsFd> OpCode for TruncateFile<S> {} | |
| unsafe impl<S: AsFd> OpCode for TruncateFile<S> {} |
No description provided.